﻿Imports System
Imports System.Net
Imports System.Net.NetworkInformation
Imports System.Text

Namespace Examples.System.Net.NetworkInformation.PingTest
    Public Class PingExamplex
        ' args[0] can be an IPaddress or host name.
        Function hacerping(url As String) As String
            Dim pingSender As New Global.System.Net.NetworkInformation.Ping
            Dim options As New PingOptions()

            ' Use the default Ttl value which is 128,
            ' but change the fragmentation behavior.
            options.DontFragment = True

            ' Create a buffer of 32 bytes of data to be transmitted.
            Dim data As String = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
            Dim buffer() As Byte = Encoding.ASCII.GetBytes(data)
            Dim timeout As Integer = 120
            Dim reply As PingReply = pingSender.Send(url, timeout, buffer, options)
            If reply.Status = IPStatus.Success Then


                hacerping = "Dirección: " & reply.Address.ToString() & _
                    " * Tiempo de respuesta :" & reply.RoundtripTime & _
                    " * Tiempo de vida:" & reply.Options.Ttl & _
                    " * Sin fragmentos: " & reply.Options.DontFragment & _
                    " * Buffer tamaño: " & reply.Buffer.Length & vbCrLf
               

            End If
        End Function
    End Class
End Namespace
